//vuex插件
export default store=>{
    //初始化  当本地存在state时把存在的state替换掉store里的state
    //store.replaceState()是store替换state特有的api
    if(localStorage.state) store.replaceState(JSON.parse(localStorage.state))
    //当有mutation更新state是触发
    store.subscribe((mutation, state) => {
        //把state存到本地
        localStorage.state = JSON.stringify(state)
    });
}